package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.entity.Employee;
import com.sky.enumclass.OperationType;
import com.sky.pojo.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
 * @author Morpeko
 * @description 针对表【category(果蔬及套餐分类)】的数据库操作Mapper
 * @createDate 2024-08-06 17:12:47
 * @Entity com.sky.pojo.Category
 */
@Mapper
public interface CategoryMapper {
    /**
     * 修改分类
     *
     * @param category
     */
    //@Update("update category set name = #{name}, sort = #{sort},id = #{id},type= #{type},create_time=#{createTime},update_time=#{updateTime},create_user=#{createUser},update_user=#{updateUser},status=#{status} where id = #{id}")
    @AutoFill(operationType = OperationType.UPDATE, description = "更新操作的自动填充")
    void updateCategory(Category category);

    /**
     * 条件分页查询分类信息
     *
     * @param category
     * @return
     */
    Page<Category> queryCategoryPage(Category category);

    /**
     * 根据ID查询分类信息
     *
     * @param category
     */
    @AutoFill(operationType = OperationType.UPDATE, description = "更新操作的自动填充")
    @Update("update category set status = #{status} where id = #{id}")
    void updateCategoryStatus(Category category);

    @AutoFill(operationType = OperationType.INSERT, description = "新增操作的自动填充")
    @Insert("insert into category(id,name,sort,type,create_time,update_time,create_user,update_user,status)" +
            " values" +
            "(#{id},#{name},#{sort},#{type},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    void saveCategory(Category category);

    /**
     * 根据ID删除分类
     *
     * @param employee
     */
    @Delete("delete from CATEGORY where id = #{id}")
    void deleteCategory(Employee employee);
}





